package com.stateflow.facade.common.util;

/**
 * Created by weiqingming on 2019/4/20.
 */
public class StringUtils {

    /**
     * 空判断
     * 
     * @param str
     * @return
     */
    public static boolean isNotEmpty(String str) {
        if (str == null || str.isEmpty()) {
            return false;
        }
        return true;
    }

    /**
     * 空判断，空格也算
     * 
     * @param str
     * @return
     */
    public static boolean isNotBlank(String str) {
        if (str == null || str.isEmpty()) {
            return false;
        }

        str = str.trim();
        return str.length() != 0;
    }

    /**
     * 判断两个字符串是否一致
     * 
     * @return
     */
    public static boolean equals(String a, String b) {
        if (a == null || b == null) {
            return false;
        }

        if (a.equals(b)){
            return true;
        }
        return false;
    }


    /**
     * 字符连接
     * @param param 等于null会返回空字符串
     * @return
     */
    public static String compose(String... param){

        if (param == null || param.length == 0){
            return "";
        }

        StringBuilder sb = new StringBuilder();
        for (String item : param){
            if (isNotEmpty(item)) {
                sb.append(item);
            }
        }

        return sb.toString();
    }
}
